package com.dindang.propertyfee.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.dindang.propertyfee.app.AppConst;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.dindang.propertyfee.di.component.DaggerFeeReceivedComponent;
import com.dindang.propertyfee.di.module.FeeReceivedModule;
import com.dindang.propertyfee.mvp.contract.FeeReceivedContract;
import com.dindang.propertyfee.mvp.presenter.FeeReceivedPresenter;

import com.dindang.propertyfee.R;


import static com.jess.arms.utils.Preconditions.checkNotNull;


public class FeeReceivedActivity extends BaseActivity<FeeReceivedPresenter> implements FeeReceivedContract.View {

    ImageView mIvBack;
    TextView mTvTitle;
    RecyclerView mListView;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerFeeReceivedComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .feeReceivedModule(new FeeReceivedModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.propertyfee_activity_fee_received; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.propertyfee_iv_back);
        mTvTitle = findViewById(R.id.propertyfee_tv_title);
        mListView = findViewById(R.id.propertyfee_listview);

        mTvTitle.setText(getIntent().getStringExtra(AppConst.DUE_RECEIVED));
        mIvBack.setOnClickListener(v -> finish());
        mPresenter.init();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public RecyclerView getListview() {
        return mListView;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }
}
